package com.lxyk.service.user.impl;

import com.lxyk.dao.user.RoleDao;
import com.lxyk.dao.user.UserDao;
import com.lxyk.domain.SysRole;
import com.lxyk.service.user.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
@Transactional
public class RoleServiceImpl implements RoleService {
    @Autowired
    private RoleDao roleDao;

    @Autowired
    private UserDao userDao;

    //添加角色
    @Override
    public void save(SysRole role) {
        roleDao.save(role);
    }

    //查询所有角色
    @Override
    public List<SysRole> findAll() {
        return roleDao.findAll();
    }

    //删除角色,同时删除中间表信息
    @Override
    public void delete(Integer id) {
        roleDao.deleteById(id);
        userDao.removeUsers(id);
    }
}
